#pragma once

#include "StructuredClassifier.h"

#include "ConnectableElement.h"
#include "Connector.h"
#include "Property.h"

namespace uml {

void StructuredClassifier::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    PartialElement::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(ownedAttributes_, "ownedAttributes", json, errorList);
    JsonSerializable::fromJsonArray(ownedConnectors_, "ownedConnectors", json, errorList);
    JsonSerializable::fromJsonArray(parts_, "parts", json, errorList);
    JsonSerializable::fromJsonArray(roles_, "roles", json, errorList);
}

void StructuredClassifier::toJson(QJsonObject& json) {
    PartialElement::toJson(json);
    JsonSerializable::toJsonArray(ownedAttributes_, "ownedAttributes", json);
    JsonSerializable::toJsonArray(ownedConnectors_, "ownedConnectors", json);
    JsonSerializable::toJsonArray(parts_, "parts", json);
    JsonSerializable::toJsonArray(roles_, "roles", json);
}

/// <summary>
/// allRoles
    /// All features of type ConnectableElement, equivalent to all direct and inherited
    /// roles.
/// </summary>
    /// <code>
    /// result = (allFeatures()->select(oclIsKindOf(ConnectableElement))->collect(oclAsType(ConnectableElement))->asSet())
    /// </code>
shared_ptr<vector<ConnectableElement>> StructuredClassifier::allRoles() const
{
    return nullptr;
}

/// <summary>
/// ownedAttributes getter
/// The Properties owned by the StructuredClassifier.
/// </summary>
vector<shared_ptr<Property>>& StructuredClassifier::ownedAttributes() {
    return ownedAttributes_;
}

/// <summary>
/// ownedConnectors getter
/// The connectors owned by the StructuredClassifier.
/// </summary>
vector<shared_ptr<Connector>>& StructuredClassifier::ownedConnectors() {
    return ownedConnectors_;
}

/// <summary>
/// parts getter
/// The Properties specifying instances that the StructuredClassifier owns by
/// composition. This collection is derived, selecting those owned Properties where
/// isComposite is true.
/// </summary>
vector<shared_ptr<Property>>& StructuredClassifier::parts() {
    return parts_;
}

/// <summary>
/// roles getter
/// The roles that instances may play in this StructuredClassifier.
/// </summary>
vector<shared_ptr<ConnectableElement>>& StructuredClassifier::roles() {
    return roles_;
}

} // namespace uml
